package com.abc.mapper;


import com.abc.bean.Bunk;
import com.abc.bean.Patient;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: bc
 * @Date: 2024-11-17 12:34
 * @Description:
 */
public interface PatientMapper {
    @Select("<script>" +
        "select " +
            "id,patient_id as patientId, " +
            "patient_name as patientName,patient_age as patientAge, " +
            "patient_gender as patientGender,patient_xx as patientXx " +
            "from patient" +
        "<where>" +
        "<if test='patientName!=null and patientName!=\"\"'>" +
        "and patient_name like concat('%',#{patientName},'%')" +
        "</if>" +
        "</where>"+
        "</script>")
    List<Patient> selectPatient(@Param("patientName") String patientName);


    @Select("select * from patient where patient_id=#{patientId}")
    Patient selectOnePatientByPatientId(String patientId);
    @Insert("insert into patient(patient_id,patient_name,patient_age,patient_gender,patient_xx) values (#{patientId},#{patientName},#{patientAge},#{patientGender},#{patientXx})")
    int addPatient(Patient patient);

    @Delete("delete from patient where id=#{id}")
    int deletePatient(String id);

    @Select("select id,patient_id as patientId,patient_name as patientName,patient_age as patientAge,patient_gender as patientGender,patient_xx as patientXx from patient where id=#{id}")
    Patient selectOnePatientById(String id);

    @Update("update patient set patient_age=#{patientAge},patient_gender=#{patientGender},patient_xx=#{patientXx} where id=#{id}")
    int updatePatientById(Patient patient);
}
